/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhanguera.tcc.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "tb_ocorrencia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ocorrencia.findAll", query = "SELECT o FROM Ocorrencia o"),
    @NamedQuery(name = "Ocorrencia.findByIdOcorrencia", query = "SELECT o FROM Ocorrencia o WHERE o.idOcorrencia = :idOcorrencia"),
    @NamedQuery(name = "Ocorrencia.findByTxOcorrencia", query = "SELECT o FROM Ocorrencia o WHERE o.txOcorrencia = :txOcorrencia"),
    @NamedQuery(name = "Ocorrencia.findByDtOcorrencia", query = "SELECT o FROM Ocorrencia o WHERE o.dtOcorrencia = :dtOcorrencia"),
    @NamedQuery(name = "Ocorrencia.findByCdCadastrador", query = "SELECT o FROM Ocorrencia o WHERE o.cdCadastrador = :cdCadastrador")})
public class Ocorrencia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_OCORRENCIA")
    private Integer idOcorrencia;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "TX_OCORRENCIA")
    private String txOcorrencia;
    @Column(name = "DT_OCORRENCIA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtOcorrencia;
    @Size(max = 45)
    @Column(name = "CD_CADASTRADOR")
    private String cdCadastrador;
    @JoinColumn(name = "COD_COMPROVANTE_ENTREGA", referencedColumnName = "ID_COMPROVANTE_ENTREGA")
    @ManyToOne
    private ComprovanteEntrega codComprovanteEntrega;
    @JoinColumn(name = "COD_CONTRATO", referencedColumnName = "ID_CONTRATO")
    @ManyToOne
    private Contrato codContrato;

    public Ocorrencia() {
    }

    public Ocorrencia(Integer idOcorrencia) {
        this.idOcorrencia = idOcorrencia;
    }

    public Ocorrencia(Integer idOcorrencia, String txOcorrencia) {
        this.idOcorrencia = idOcorrencia;
        this.txOcorrencia = txOcorrencia;
    }

    public Integer getIdOcorrencia() {
        return idOcorrencia;
    }

    public void setIdOcorrencia(Integer idOcorrencia) {
        this.idOcorrencia = idOcorrencia;
    }

    public String getTxOcorrencia() {
        return txOcorrencia;
    }

    public void setTxOcorrencia(String txOcorrencia) {
        this.txOcorrencia = txOcorrencia;
    }

    public Date getDtOcorrencia() {
        return dtOcorrencia;
    }

    public void setDtOcorrencia(Date dtOcorrencia) {
        this.dtOcorrencia = dtOcorrencia;
    }

    public String getCdCadastrador() {
        return cdCadastrador;
    }

    public void setCdCadastrador(String cdCadastrador) {
        this.cdCadastrador = cdCadastrador;
    }

    public ComprovanteEntrega getCodComprovanteEntrega() {
        return codComprovanteEntrega;
    }

    public void setCodComprovanteEntrega(ComprovanteEntrega codComprovanteEntrega) {
        this.codComprovanteEntrega = codComprovanteEntrega;
    }

    public Contrato getCodContrato() {
        return codContrato;
    }

    public void setCodContrato(Contrato codContrato) {
        this.codContrato = codContrato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOcorrencia != null ? idOcorrencia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ocorrencia)) {
            return false;
        }
        Ocorrencia other = (Ocorrencia) object;
        if ((this.idOcorrencia == null && other.idOcorrencia != null) || (this.idOcorrencia != null && !this.idOcorrencia.equals(other.idOcorrencia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.anhanguera.tcc.model.Ocorrencia[ idOcorrencia=" + idOcorrencia + " ]";
    }

}
